<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>7.模拟一个数据监测</title>
</head>

<body>

    <script type="text/javascript">
        let data = {
            name: '奇瑞',
            address: '合肥花园大道'
        }
        const obs = new Observe(data);
        console.log(obs);

        // 准备一个 vm 实例对象
        let vm = {};
        vm._data = data = obs;


        function Observe(obj) {
            const keys = Object.keys(obj);
            keys.forEach(k => {
                Object.defineProperty(this, k, {
                    get() {
                        return obj[k];
                    },
                    set(val) {
                        console.log(`${k}被改了，我要去解析模版，生成虚拟DOM......我要开始干活了`)
                    }
                })
            });
        }
    </script>

</body>

</html>